//package com.kyzh.core.pager.gamelist
//
//
//import android.os.Bundle
//import android.util.Log
//import android.view.LayoutInflater
//import android.view.View
//import android.view.ViewGroup
//import androidx.fragment.app.Fragment
//import androidx.recyclerview.widget.LinearLayoutManager
//import androidx.recyclerview.widget.RecyclerView
//import com.gushenge.core.base.fragment.BaseFragment
//import com.gushenge.core.base.fragment.BaseVmDbFragment
//import com.gushenge.core.base.viewmodel.BaseViewModel
//import com.gushenge.core.beans.*
//import com.gushenge.core.impls.GameImpl
//import com.gushenge.core.listeners.ResultListener
//import com.gushenge.core.requests.GameRequest
//import com.kyzh.core.R
//import com.kyzh.core.adapters.*
//import com.kyzh.core.adapters.v3.GameListBorderAdapter
//import com.kyzh.core.databinding.FragmentSortNewBinding
//import com.kyzh.core.databinding.HeaderTopSortBinding
//import com.kyzh.core.databinding.ItemFooterSortBinding
//import com.kyzh.core.pager.gamedetail.GMGameDetailActivity1
//import com.kyzh.core.utils.setVisibility
//import com.kyzh.core.utils.startGameDetailActivity
//import com.kyzh.core.utils.startGameDetailActivity2
//import kotlinx.android.synthetic.main.fragment_sort.*
//import org.jetbrains.anko.support.v4.dip
//import org.jetbrains.anko.support.v4.onRefresh
//
///**
// * A simple [Fragment] subclass.
// */
//class GMNewFragment :
//    BaseVmDbFragment<BaseViewModel, FragmentSortNewBinding>(R.layout.fragment_sort_new) {
//    override fun reloadClick() {
//
//    }
//
//    var position = 0
//
//    // 左侧的
//    lateinit var leftAdapter: SortLeftAdapter
//    var mp = 1
//    var type = 0
//
//    //推荐的头
//    lateinit var firstHeader: HeaderTopSortBinding
//
//    // 推荐的adapter
//    lateinit var chosenAdapter: SortChosenAdapter1
//
//
//    //
//    lateinit var listAdapter: GameListBorderAdapter
//
//    //
//    lateinit var bind: ItemFooterSortBinding
//
//    lateinit var sortOtherTypeAdapter: GameListBorderAdapter
//
//    override fun initView(savedInstanceState: Bundle?) {
//        firstHeader = HeaderTopSortBinding.inflate(layoutInflater)
//        db.right.layoutManager = LinearLayoutManager(context)
//        chosenAdapter = SortChosenAdapter1()
//        listAdapter = GameListBorderAdapter(R.layout.item_game_border, null)
//        bind = ItemFooterSortBinding.inflate(layoutInflater)
//        sortOtherTypeAdapter =
//            GameListBorderAdapter(R.layout.item_game_border, null)
//        bind.revFoot.adapter = sortOtherTypeAdapter
//        bind.revFoot.layoutManager = LinearLayoutManager(requireContext())
//        GameRequest.gmSort {
//            loadSir.showSuccess()
//            // 顶部banner
//            it[position].color = requireActivity().resources.getColor(R.color.colorPrimary)
//            it[position].bgcolor = requireActivity().resources.getColor(R.color.white)
//            leftAdapter = SortLeftAdapter(R.layout.frag_sort_item, it)
//            sort_recyclerview.layoutManager =
//                LinearLayoutManager(requireActivity(), RecyclerView.VERTICAL, false)
//            sort_recyclerview.adapter = leftAdapter
//            // 加载默认
//            type = it[position].id
//            leftAdapter.setOnItemClickListener { adapter, view, pos ->
//                mp = 1
//                this.position = pos
//                resetColor(it)
//                it[pos].color = requireActivity().resources.getColor(R.color.colorPrimary)
//                it[pos].bgcolor = requireActivity().resources.getColor(R.color.white)
//                leftAdapter.notifyDataSetChanged()
//                type = it[pos].id
//                if (position == 0) {
//                    initChosen()
//                } else {
//                    initRight()
//                }
//                return@setOnItemClickListener
//            }
//        }
//        initChosen()
//        db.swipe.onRefresh {
//            mp = 1
//            if (position == 0) {
//                initChosen()
//            } else {
//                initRight()
//            }
//        }
//    }
//
//    // 推荐页
//    fun initChosen() {
//        GameRequest.chosenGM(mp, 1) {
//            db.swipe.isRefreshing = false
//            chosenAdapter.loadMoreModule.loadMoreComplete()
//            if (mp > this.max_p) {
//                chosenAdapter.loadMoreModule.loadMoreEnd(true)
//            }
//            db.right.adapter = chosenAdapter
//            chosenAdapter.setNewInstance(this.tuijian)
//        }
//        chosenAdapter.setOnItemClickListener { adapter, view, position ->
//            val any = adapter.data[position] as Game
//            GMGameDetailActivity1.start(requireContext(), any.gid, type = "gm")
//        }
//
//        chosenAdapter.loadMoreModule.setOnLoadMoreListener {
//            mp++
//            GameRequest.chosenGM(mp) {
//                chosenAdapter.addData(this.data!!)
//                chosenAdapter.loadMoreModule.loadMoreComplete()
//                if (mp > max_p) {
//                    chosenAdapter.loadMoreModule.loadMoreEnd(true)
//                }
//            }
//        }
//    }
//
//
//    //其他页
//    fun initRight() {
//        GameRequest.chosenGM(mp, type) {
//            right.adapter = listAdapter
//            db.swipe.isRefreshing = false
//            listAdapter.setNewInstance(this.data)
//            listAdapter.loadMoreModule.loadMoreComplete()
//            if (mp >= this.max_p) {
//                listAdapter.loadMoreModule.loadMoreEnd(true)
//            }
//            listAdapter.removeAllFooterView()
//            if (this.tuijian!!.isNotEmpty()) {
//                sortOtherTypeAdapter.setNewInstance(this.tuijian)
//                listAdapter.addFooterView(bind.root)
//            }
//        }
//        listAdapter.loadMoreModule.setOnLoadMoreListener {
//            mp++
//            GameRequest.chosenGM(mp, type) {
//                listAdapter.addData(this.data!!)
//                listAdapter.removeAllFooterView()
//                listAdapter.loadMoreModule.loadMoreComplete()
//                if (mp >= this.max_p) {
//                    listAdapter.loadMoreModule.loadMoreEnd(true)
//                }
//                if (this.tuijian!!.isNotEmpty()) {
//                    sortOtherTypeAdapter.setNewInstance(this.tuijian)
//                    listAdapter.addFooterView(bind.root)
//                }
//            }
//        }
//    }
//
//    /*
//       * 重置左边栏颜色
//       * */
//    private fun resetColor(lists: MutableList<Sort>) {
//        for (i in lists) {
//            i.color = requireActivity().resources.getColor(R.color.bg_f7)
//            i.bgcolor = requireActivity().resources.getColor(R.color.bg_f7)
//        }
//    }
//
//    override fun lazyLoadData() {
//    }
//
//
//}
